Skip to content

Commit

Permalink
Fix GeckoView tile loading android assets folder (#4478)
Browse files Browse the repository at this point in the history
* Fix vector tiles not loading when html is opened via "resource://android" (i.e., the assets folder) in GeckoView on Android

* Add changelog entry

* Add test

---------

Co-authored-by: Joe Woodward <[email protected]>
  • Loading branch information
jwoodwardtfx and Joe Woodward authored Jul 31, 2024
1 parent 04e39c5 commit 19c79bb
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
- Fix remove hash string when map is removed ([#4427](https://github.com/maplibre/maplibre-gl-js/pull/4427))
- Fix GeolocateControl may be added twice when calling addControl/removeControl/addControl rapidly ([#4454](https://github.com/maplibre/maplibre-gl-js/pull/4454))
- Fix `style.loadURL` abort error being logged when removing style ([#4425](https://github.com/maplibre/maplibre-gl-js/pull/4425))
- Fix vector tiles not loading when html is opened via "resource://android" (i.e., the assets folder) in GeckoView on Android ([#4451](https://github.com/maplibre/maplibre-gl-js/pull/4451))
- _...Add new stuff here..._

## 4.5.0
Expand Down
14 changes: 14 additions & 0 deletions src/util/actor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,4 +201,18 @@ describe('Actor', () => {

expect(spy).toHaveBeenCalled();
});

test('should process a message when origin is "resource://android"', async () => {
const worker = workerFactory() as any as WorkerGlobalScopeInterface & ActorTarget;
const actor = new Actor(worker, '1');

const spy = jest.fn().mockReturnValue(Promise.resolve({}));
worker.worker.actor.registerMessageHandler(MessageType.getClusterExpansionZoom, spy);

actor.target.postMessage({type: MessageType.getClusterExpansionZoom, data: {} as any, origin: 'resource://android'});

await sleep(0);

expect(spy).toHaveBeenCalled();
});
});
2 changes: 1 addition & 1 deletion src/util/actor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export class Actor implements IActor {
receive(message: {data: MessageData}) {
const data = message.data;
const id = data.id;
if (data.origin !== 'file://' && location.origin !== 'file://' && data.origin !== location.origin) {
if (data.origin !== 'file://' && location.origin !== 'file://' && data.origin !== 'resource://android' && location.origin !== 'resource://android' && data.origin !== location.origin) {
return;
}
if (data.targetMapId && this.mapId !== data.targetMapId) {
Expand Down

0 comments on commit 19c79bb

Please sign in to comment.