plateaukao / einkbro

A small, fast web browser based on Android WebView. It's tailored for E-Ink devices but also works great on normal android devices.
Other
1.05k stars 77 forks source link

NPE in epub saving / handling mediatype #361

Closed uqs closed 3 months ago

uqs commented 3 months ago

einkbro v11.6.0

Go to https://antithesis.com/blog/is_something_bugging_you/

  1. Save as Epub will download some images, then crash:
    --------- beginning of crash
    03-29 15:22:25.805 26818 26818 E AndroidRuntime: FATAL EXCEPTION: main
    03-29 15:22:25.805 26818 26818 E AndroidRuntime: Process: info.plateaukao.einkbro, PID: 26818
    03-29 15:22:25.805 26818 26818 E AndroidRuntime: java.lang.NullPointerException: getMediaTypeByName(...) must not be null
    03-29 15:22:25.805 26818 26818 E AndroidRuntime:        at v5.e.u(SourceFile:131)
    03-29 15:22:25.805 26818 26818 E AndroidRuntime:        at s6.a.q(SourceFile:1)
    03-29 15:22:25.805 26818 26818 E AndroidRuntime:        at j7.b0.run(SourceFile:1)
    03-29 15:22:25.805 26818 26818 E AndroidRuntime:        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    03-29 15:22:25.805 26818 26818 E AndroidRuntime:        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
    03-29 15:22:25.805 26818 26818 E AndroidRuntime:        at java.lang.Thread.run(Thread.java:1012)
    03-29 15:22:25.805 26818 26818 E AndroidRuntime:        Suppressed: o7.f: [i1{Cancelling}@5a3a031, Dispatchers.Main]

I don't have access to Android Studio right now, so I can only try next week to debug this further.

  1. More interesting though is, when I turn on Reader mode on this page, it seems to re-render it just fine, but then I can no longer scroll the page at all (this doesn't reproduce in Firefox reader mode ...)
plateaukao commented 3 months ago

@uqs it should have been fixed in snapshot version.

As for scrolling in reader mode, i don't know why. it looks like the original site use some kind of mechanism to control content scrollling. When converting to reader mode, it's no longer working (since I remove most of css styles in reader mode)

uqs commented 3 months ago

Thanks for the quick fix!

uqs commented 3 months ago

For the record, the issue on that site was the webp, which their servers return with a content-type of application/octet-stream

% curl -I https://antithesis.com/blog/is_something_bugging_you/images/robo_bugs_opt.webp
HTTP/2 200 
content-type: application/octet-stream
...

and I think we're using this library here, but with the server not giving us any useful mimetype, there's nothing really one can do, other than maybe parse the URL and infer the most likely mimetype from the extension, if present.

uqs commented 3 months ago

By "here" I meant https://github.com/psiegman/epublib/blob/master/epublib-core/src/main/java/nl/siegmann/epublib/service/MediatypeService.java